@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: '采购计划协议项目计划行'
@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions: true
define root view entity ZI_SchedglineAPI
  as select from    I_SchedgagrmthdrApi01 as _SAHdr
    inner join      I_SchedgAgrmtItmApi01 as _SAItm           on  _SAItm.SchedulingAgreement            = _SAHdr.SchedulingAgreement
                                                              and _SAItm.PurchasingDocumentDeletionCode = ''
    inner join      I_SchedglineApi01     as _SASchLine       on  _SASchLine.SchedulingAgreement     = _SAItm.SchedulingAgreement
                                                              and _SASchLine.SchedulingAgreementItem = _SAItm.SchedulingAgreementItem
    left outer join I_BusinessPartner     as _businesspartner on _businesspartner.BusinessPartner = _SAHdr.Supplier
    left outer join I_ProductText         as _ProductText     on  _ProductText.Product  = _SAItm.Material
                                                              and _ProductText.Language = '1'

{

  key _SASchLine.SchedulingAgreement,
  key _SASchLine.SchedulingAgreementItem,
  key _SASchLine.ScheduleLine,
      _SAHdr.CompanyCode,
      _SAHdr.Supplier,
      _SAItm.Material                                                                                    as product,
      concat( concat( concat( _businesspartner.BusinessPartnerName, '(' ), _SAHdr.Supplier ), ')' )      as SupplierName,
      concat( concat( concat( _ProductText.ProductName, '(' ), _SAItm.Material ), ')' )                  as ProductName,
      _SASchLine.ScheduleLineDeliveryDate,
      cast( _SASchLine.ScheduleLineOrderQuantity as abap.dec( 13,3 ) )                                   as ScheduleLineOrderQuantity,
      cast( _SASchLine.ScheduleLineOrderQuantity - _SASchLine.RoughGoodsReceiptQty as abap.dec( 13,3 ) ) as unclearQuantity,
      case when _SASchLine.ScheduleLineIsFixed = 'X' then '是' else '否' end                               as ScheduleLineIsFixed
}
where
  _SASchLine.ScheduleLineOrderQuantity > _SASchLine.RoughGoodsReceiptQty
